package ci;

import java.io.IOException;
import java.util.HashMap;
import java.util.SortedMap;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ci.model.RecomendationsCI;
import ci.model.Tester2;

/**
 * Servlet implementation class Recomendation
 */
public class Recomendation extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Recomendation() {
        super();
        // TODO Auto-generated constructor stub
    }
	
	
	  protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	    	RecomendationsCI sm = new RecomendationsCI();
	    	HashMap<String,HashMap> persons = sm.info();
	    	
	    	String person1 = (String) request.getParameter("cmbRecomendacion");
	    	SortedMap<Double, String> recomendationEuc = RecomendationsCI.getRecomendations(persons, person1, 1);
	    	

	    	SortedMap<Double, String> recomendationPear = RecomendationsCI.getRecomendations(persons, person1, 2);
	    	
	    	request.setAttribute("recomendationEuc", recomendationEuc);
	    	
	    	request.setAttribute("recomendationPear", recomendationPear);
	    	
	    	request.setAttribute("nomRecomendation", person1);

			RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher("/similitud2.jsp");
			requestDispatcher.forward(request, response);

	    }

}
